{extend name="public:layout" /}
{block name="title"}{$moudleName}列表{/block}
{block name="head"}

{/block}
{block name="body"}
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <ol class="breadcrumb">
                    <li class="active"><i class="fa fa-hand-o-right"></i> {$moudleName}列表</li>
                </ol>
            </ol>
        </div>
        <div class="ibox-content">
            <div class="toolbar">
                <div class="pull-left">
                    <form class="form-inline" id="searchForm" method="post">
                        <div class="form-group">
                            <input class="form-control" type="text" placeholder="车牌号" name="car_sn" value="{$query.car_sn}" style="width:80px" />
                        </div>
                        <div class="form-group">
                            <input class="form-control" type="text" placeholder="座位数" name="seat" value="{$query.seat}" style="width:80px" />
                        </div>
                        <!--
                        <div class="form-group">
                            <input class="form-control" type="text" name="btime" value="{$query.btime}" readonly />
                        </div>
                        <div class="form-group">
                            <input class="form-control" type="text" name="etime" value="{$query.etime}" readonly />
                        </div>
                        <div class="form-group">
                            <input class="form-control" type="text" placeholder="日期间隔" name="date_day" value="{$query.date_day}" style="width:60px" />
                        </div>
                         -->
                        <button type="submit" class="btn btn-info"><i class="fa fa-search"></i> 搜索</button>
                        <a class="btn btn-white" href="{:url('index',['mid'=>$Request.param.mid])}">
                            <i class="fa fa-trash"></i> 清空
                        </a>
                    </form>
                </div>
                <div class="pull-right">
                    已选择<span id="car_num" class="text-danger">0</span>辆车
                </div>
                <div class="clearfix"></div>
            </div>
            <table class="table table-bordered" id="grid">
                <tr>
                    <th>#</th>
                    <th>车牌号</th>
                    <th>所属单位</th>
                    <th>座位数</th>
                    <th>油耗</th>
                    <th>当前状态</th>
                </tr>
                {volist name="list" id="vo"}
                <tr>
                    <td>
                        <input name="car_sn[]" type="checkbox" data-self="{$vo.btype_aid}" class="checkbox" value="{$vo.car_sn}" />
                    </td>
                    <td>
                        {eq name="vo.btype_aid" value="1"}
                        <span class="label label-success">{$vo.car_sn}</span>
                        {else/}
                        <span class="label label-warning">{$vo.car_sn}</span>
                        {/eq}
                    </td>
                    <td>
                        {eq name="vo.btype_aid" value="1"}
                        自有车辆
                        {else/}
                        {:get_field_value('car_btype','title',['aid'=>$vo.btype_aid])}
                        {/eq}
                    </td>
                    <td>{$vo.car_seat}</td>
                    <td>{$vo.car_fue}</td>
                    <td>{$vo.car_status_text}</td>
                </tr>
                {/volist}
            </table>
            <input id="cars" type="hidden" value="" />
            <input id="is_self" type="hidden" value="" />
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    $(function () {
        $('.checkbox').change(function () {
            var isself = '';
            var reVal = '';
            var car_num=0;
            $("#grid :checkbox").each(function () {
                if ($(this).prop("checked")) {
                    isself += $(this).data('self') + ",";
                    reVal += $(this).val() + ",";
                    car_num+=1;
                }
            });
            isself = isself.substr(0, isself.length - 1);
            reVal = reVal.substr(0, reVal.length - 1);
            $('#cars').val(reVal);
            $('#is_self').val(isself);
            $('#car_num').text(car_num);
        });
    })
</script>
{/block}